import scrapy


class Lx1Spider(scrapy.Spider):
    name = "lx1"
    start_urls = [f"https://www.55188.com/forum.php?mod=my&ac=treasure_sell&op=indicatorsrank&page={page}" for page in range(1,4)]


    def parse(self, response):
        items = response.xpath('//div[@class="rank-main"]//ul[@class="rank-box"]')
        for item in items:
            id = item.xpath('li[@class="rk-1"]/em/text()').get()
            name = item.xpath('li[@class="rk-2 wrap"]/a/text()').get()
            good = item.xpath('li[@class="rk-3"]/cite/text()').get()
            good_number = item.xpath('li[@class="rk-4"]/cite/text()').get()
            author = item.xpath('li[@class="rk-5"]/a/text()').get()
            time = item.xpath('li[@class="rk-6"]/text()').get()
            dict1 = {
                '排名': id,
                '指标名': name,
                '好评率': good,
                '好评数量': good_number,
                '作者': author,
                '发布时间': time,
            }
            print(dict1)

        print("*"*150)
